import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import Convert from '../views/Convert.vue'
import Generate from '../views/Generate.vue'
import Defense from '../views/Defense.vue'
import Templates from '../views/Templates.vue'
import Profile from '../views/Profile.vue'
import TemplateDetail from '../views/TemplateDetail.vue'
import UsageHistory from '../views/UsageHistory.vue'
import Membership from '../views/Membership.vue'
import Help from '../views/Help.vue'
import About from '../views/About.vue'
import Tools from '../views/Tools.vue'
import CaseAnalysis from '../views/CaseAnalysis.vue'
import JurisdictionAnalysis from '../views/JurisdictionAnalysis.vue'
import LitigationCostCalculator from '../views/LitigationCostCalculator.vue'
import FilingGuide from '../views/FilingGuide.vue'
import LegalConsultation from '../views/LegalConsultation.vue'
import EnterpriseDisplay from '../views/EnterpriseDisplay.vue'
import CaseAdd from '../views/CaseAdd.vue'
import DefenseConvert from '../views/DefenseConvert.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: { title: '首页' }
  },
  {
    path: '/convert',
    name: 'Convert',
    component: Convert,
    meta: { title: '诉状转换' }
  },
  {
    path: '/generate',
    name: 'Generate',
    component: Generate,
    meta: { title: '诉状生成' }
  },
  {
    path: '/defense',
    name: 'Defense',
    component: Defense,
    meta: { title: '答辩状生成' }
  },
  {
    path: '/templates',
    name: 'Templates',
    component: Templates,
    meta: { title: '诉状模板' }
  },
  {
    path: '/profile',
    name: 'Profile',
    component: Profile,
    meta: { title: '个人中心' }
  },
  {
    path: '/template/:name',
    name: 'TemplateDetail',
    component: TemplateDetail,
    meta: { title: '文书详情' }
  },
  {
    path: '/usage-history',
    name: 'UsageHistory',
    component: UsageHistory,
    meta: { title: '文件列表' }
  },
 
  {
    path: '/membership',
    name: 'Membership',
    component: Membership,
    meta: { title: '会员中心' }
  },
  
  {
    path: '/help',
    name: 'Help',
    component: Help,
    meta: { title: '帮助中心' }
  },
  {
    path: '/about',
    name: 'About',
    component: About,
    meta: { title: '关于我们' }
  },
  {
    path: '/tools',
    name: 'Tools',
    component: Tools,
    meta: { title: '工具' }
  },
  {
    path: '/case-analysis',
    name: 'CaseAnalysis',
    component: CaseAnalysis,
    meta: { title: '案由分析' }
  },
  {
    path: '/jurisdiction-analysis',
    name: 'JurisdictionAnalysis',
    component: JurisdictionAnalysis,
    meta: { title: '管辖权分析' }
  },
  {
    path: '/litigation-fee-calculator',
    name: 'LitigationCostCalculator',
    component: LitigationCostCalculator,
    meta: { title: '诉讼费计算' }
  },
  {
    path: '/filing-guide',
    name: 'FilingGuide',
    component: FilingGuide,
    meta: { title: '立案指引' }
  },
  {
    path: '/legal-consultation',
    name: 'LegalConsultation',
    component: LegalConsultation,
    meta: { title: '法律咨询' }
  },
  {
    path: '/enterprise-display',
    name: 'EnterpriseDisplay',
    component: EnterpriseDisplay,
    meta: { title: '企业展示' }
  },
  {
    path: '/case-add',
    name: 'CaseAdd',
    component: CaseAdd,
    meta: { title: '新增案件' }
  },
  {
    path: '/defense-convert',
    name: 'DefenseConvert',
    component: DefenseConvert,
    meta: { title: '答辩状转换' }  
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '要素式诉状小程序'
  next()
})

export default router 